package tmts.commands;

import tmts.Server;

public class SetSpeed extends Command
{

    public SetSpeed(Server s)
    {
        super(s);
    }

    @Override
    public String getActionString()
    {
        return "setspeed";
    }

    @Override
    public String execute(String[] command)
    {
        if (command.length != 2)
        {
            return "Command not formed properly. The format has to be 'SetSpeed <number>'";
        } else
        {
            try
            {
                int speed = Integer.parseInt(command[1]);
                server.setSimulateSpeed(speed);
                return "Simulate speed now at " + speed + "x";
            } catch (NumberFormatException e)
            {
                return "Please enter a valid number";
            }
        }
    }

}
